import { defineStore } from 'pinia'
import getCurrentTime from '@/utils/getTime'

export const useMainDataStore = defineStore('mainData', () => {
  /** false: dark,  true: light  */
  const sysTheme = ref(false)

  // timeDate 的类型因该是 getCurrentTime 的返回的对象的类型
  const timeDate = reactive(getCurrentTime())

  // 设置中的数据
  const defaultNewsArr = ref<newsType[]>([
    {
      label: '哔哩哔哩',
      name: 'bilibili',
      order: 0,
      show: true
    },
    {
      label: '微博',
      name: 'weibo',
      order: 1,
      show: true
    },
    {
      label: 'IT之家',
      name: 'ithome',
      order: 2,
      show: true
    },
    {
      label: '百度贴吧',
      name: 'tieba',
      order: 3,
      show: true
    },
    {
      label: '稀土掘金',
      name: 'juejin',
      order: 4,
      show: true
    },
    {
      label: '原神',
      name: 'genshin',
      order: 5,
      show: true
    },
    {
      label: 'HelloGitHub',
      name: 'hellogithub',
      order: 6,
      show: true
    }
  ])
  // 当前展示新闻类别, 这个先写死.
  const newsArr = ref<newsType[]>([
    {
      label: '哔哩哔哩',
      name: 'bilibili',
      order: 0,
      show: true
    },
    {
      label: '微博',
      name: 'weibo',
      order: 1,
      show: true
    },
    {
      label: 'IT之家',
      name: 'ithome',
      order: 2,
      show: true
    },
    {
      label: '百度贴吧',
      name: 'tieba',
      order: 3,
      show: false
    }
  ])

  return { sysTheme, timeDate, defaultNewsArr, newsArr }
})
